package io.renren.modules.order_pay.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.order.entity.V9OrderEntity;
import io.renren.modules.order.service.V9OrderService;
import io.renren.modules.order_pay.entity.V9OrderPayEntity;
import io.renren.modules.order_pay.service.V9OrderPayService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 支付信息
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-09-19 18:21:20
 */
@RestController
@RequestMapping("order_pay/v9orderpay")
public class V9OrderPayController {
    @Autowired
    private V9OrderPayService v9OrderPayService;
    @Autowired
    private V9OrderService v9OrderService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("order_pay:v9orderpay:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = v9OrderPayService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{payId}")
    @RequiresPermissions("order_pay:v9orderpay:info")
    public R info(@PathVariable("payId") Integer payId){
		V9OrderPayEntity v9OrderPay = v9OrderPayService.getById(payId);
        V9OrderEntity v9Order = v9OrderService.getOne(new QueryWrapper<V9OrderEntity>().eq("pay_id",payId));

        return R.ok().put("v9OrderPay", v9OrderPay).put("order",v9Order);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("order_pay:v9orderpay:save")
    public R save(@RequestBody V9OrderPayEntity v9OrderPay){
		v9OrderPayService.save(v9OrderPay);
		V9OrderEntity v9OrderEntity=new V9OrderEntity();
		//Integer oderid=v9OrderService.insertGetId(v9OrderEntity);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("order_pay:v9orderpay:update")
    public R update(@RequestBody V9OrderPayEntity v9OrderPay){
		v9OrderPayService.updateById(v9OrderPay);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("order_pay:v9orderpay:delete")
    public R delete(@RequestBody Integer[] payIds){
		v9OrderPayService.removeByIds(Arrays.asList(payIds));

        return R.ok();
    }

}
